#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
    srand(time(NULL));
    unsigned int val = rand() % 100;

    int temp = 0;
    int maxtemp = 100;
    int mintemp = 0;

    printf("来玩猜大小\n\n");

    while (1)
    {
        printf("请输入一个数字(%d~%d):",mintemp,maxtemp);
        scanf("%d", &temp);
        if (temp > val)
        {
            if (temp >= maxtemp)
            {
                printf("输入错误,应输入%d~%d之间的数\n", mintemp, maxtemp);
            }
            else
            {
                maxtemp = temp;
                printf("数字大了,应在%d~%d之间\n", mintemp, maxtemp);
            }
        }
        else if (temp < val)
        {
            if (temp <= mintemp)
            {
                printf("输入错误,应输入%d~%d之间的数\n", mintemp, maxtemp);
            }
            else
            {
                mintemp = temp;
                printf("数字小了,应在%d~%d之间\n", mintemp, maxtemp);
            }
        }
        else
        {
            printf("恭喜答对~\n");
            break;
        }
    }

    return 0;
}
